package io;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;

/**
 * 缓冲流：是一对高级流，作用是加快读写效率
 * BufferedInputStream：缓冲输入流
 * BufferedOutputStream：缓冲输出流
 */
public class CopyDemo3Buffered {
    public static void main(String[] args) throws Exception {
        FileInputStream fis = new FileInputStream("guilin.jpg");
        FileOutputStream fos = new FileOutputStream("guiling.jpg");

        BufferedInputStream bis = new BufferedInputStream(fis);
        BufferedOutputStream bos = new BufferedOutputStream(fos);

        int d;
        long start = System.currentTimeMillis();
        while ((d= bis.read())!=-1){
            bos.write(d);
        }
        System.out.println("复制完成");

        bis.close();
        bos.close();
        long end = System.currentTimeMillis();
        System.out.println("耗时："+(end-start));

    }
}
